| Conditions | 7 |
| Total Lines | 55 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import { getGlobalConfiguration, SETTINGS_websiteHideUnusedTabs, SETTINGS_websiteOptimizeListAppearance } from '../configuration/configuration'; |
||
| 3 | |||
| 4 | export function init(): void { |
||
| 5 | getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => { |
||
| 6 | // if disabled, add class to avoid our css optimizations |
||
| 7 | if (!value) { |
||
| 8 | let disableFunc = (node: Element) => { |
||
| 9 | let disableNode = (node: Element) => { |
||
| 10 | node.classList.add('awp-hide-unused-disabled') |
||
| 11 | } |
||
| 12 | |||
| 13 | if (node.tagName === 'MD-TAB-ITEM') { |
||
| 14 | disableNode(node); |
||
| 15 | } |
||
| 16 | else { |
||
| 17 | node.querySelectorAll('md-tab-item').forEach(node => disableNode(node)); |
||
| 18 | } |
||
| 19 | }; |
||
| 20 | |||
| 21 | core.registerScript((node: Node) => { |
||
| 22 | if (node instanceof Element) { |
||
| 23 | disableFunc(node); |
||
| 24 | } |
||
| 25 | }, ".*"); |
||
| 26 | |||
| 27 | core.runAfterLoad(() => { |
||
| 28 | disableFunc(document.body); |
||
| 29 | }, ".*"); |
||
| 30 | } |
||
| 31 | }); |
||
| 32 | |||
| 33 | getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => { |
||
| 34 | // if disabled, add class to avoid our css optimizations |
||
| 35 | if (!value) { |
||
| 36 | let disableFunc = (node: Element) => { |
||
| 37 | let disableNode = (node: Element) => { |
||
| 38 | node.classList.add('awp-list-disabled') |
||
| 39 | } |
||
| 40 | |||
| 41 | if (node.tagName === 'MD-LIST-ITEM') { |
||
| 42 | disableNode(node); |
||
| 43 | } |
||
| 44 | else { |
||
| 45 | node.querySelectorAll('md-list-item').forEach(node => disableNode(node)); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | core.registerScript(node => { |
||
| 50 | if (node instanceof Element) { |
||
| 51 | disableFunc(node); |
||
| 52 | } |
||
| 53 | }, ".*"); |
||
| 54 | |||
| 55 | core.runAfterLoad(() => { |
||
| 56 | disableFunc(document.body); |
||
| 57 | }, ".*"); |
||
| 58 | } |
||
| 60 | } |